<?php
    /**
 * View
 *
 *@author S.Feil, T.Ziegler, M.El-Hindi <goatymail@googlemail.com>
 *27 May 2012
 *@copyright Copyright (c) 2012, S.Feil, T.Ziegler, M.El-Hindi
 *@package cms
 *
 */
/**
 * Class View
 * passes data to template
 *
 *@package lib
 */
    class View{
        /**
         * 
         * @var string $sTemplate HTML template that presents the data to user
         */
        private $sTemplate = '';
        
        /**
         * 
         * @var array $aDisplayedContent Used to pass data to the template. 
         * The template of the view access the array to view the data
         */
        private $aDisplayedContent = array();
        
        /**
         * Set template of the view
         * Every view has one template
         * @param string $sFullTemplatePath Template the data is passed to
         */
        public function __construct($sFullTemplatePath){
            $this->sTemplate = $sFullTemplatePath;
        }
                
        /**
         * Stores the data in the aDisplayedContent array
         * @param string $sKey Key to access data in the array
         * @param string $sValue Data to be stroed
         */
        public function assign($sKey, $sValue){
		    $this->aDisplayedContent[$sKey] = $sValue;
	    }

        public function display(){
			//Every echoed output will be stored in a buffer
			ob_start();
			
			//include template and store template contents $output
			include_once($this->sTemplate);
			$output = ob_get_contents();
			ob_end_clean();
			
			//return output
			return $output;
		}
        
		/**
		 * Setter function for $sTemplate
		 * @param string $sFullTemplatePath
		 */
		public function _setTemplate($sFullTemplatePath){
		    $this->sTemplate = $sFullRemplatePath;
		}
        
    }
?>